package basics;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class InvokeMethodWithPrimitives {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        try {
            Object obj = new int[]{1, 2, 3};
            Method m = obj.getClass().getMethod("hashCode");
            int code = (Integer) m.invoke(obj);
            System.out.println(code);
        } catch (NoSuchMethodException e) {
            System.out.println("No declared method with the given name can be invoked" +
                    ",the reason can be: \n 1. The method is not declared in this class" +
                    "\n 2. The method is not public");
        }

    }
}
